package cn.edu.ncepu.junit.learn;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.junit.jupiter.MockitoExtension;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.verify;

/**
 *
 * 2025-11-05
 *
 * @author 醒过来摸鱼
 */
@ExtendWith(MockitoExtension.class)
class SpyServiceTest {

    @InjectMocks
    private SpyService spyService;

    @Spy
    private SpyDao spyDao = new SpyDao();

    @Test
    void call() {
        Mockito.doReturn("醒过来摸鱼").when(spyDao).step2();
        assertEquals("Hello, 醒过来摸鱼", spyService.call());
        verify(spyDao).step1();
        verify(spyDao).step3();
    }
}